package com.example.systemend.service.echartsImpl;

import com.example.systemend.Mapper.GoodsMapper;
import com.example.systemend.pojo.Goods;
import com.example.systemend.pojo.Pie;
import com.example.systemend.pojo.SevenDay;
import com.example.systemend.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 权哥
 * @version 1.0
 * @date 2022/6/7 11:39
 */
@Service
public class EchartsServiceImpl implements EchartsService {

    @Autowired
    GoodsMapper goodsMapper;

//    七天销售额
    @Override
    public List<SevenDay> getSevenSales() {
        List<SevenDay> sevenDaySales=new ArrayList<>();
        GetDay getDay=new GetDay();
        for(int i=0;i<getDay.getSumDate(7).size();i++){
            SevenDay sevenDay=new SevenDay();
            sevenDay.setToday(getDay.getSumDate(7).get(i));
            sevenDay.setToday_sales_money(goodsMapper.today_sales_money(getDay.getSumDate(7).get(i)));
//            System.out.println(getDay.getSumDate(7).get(i)+"销售额为："+
//                    goodsMapper.today_sales_money(getDay.getSumDate(7).get(i)));
            sevenDaySales.add(sevenDay);
        }

        return sevenDaySales;
    }

    //15天毛利润
    @Override
    public List<SevenDay> getProfit() {

        List<SevenDay> profit=new ArrayList<>();
        GetDay getDay=new GetDay();
        for(int i=0;i<getDay.getSumDate(15).size();i++){
            SevenDay sevenDay=new SevenDay();
            sevenDay.setToday(getDay.getSumDate(15).get(i));
            sevenDay.setToday_sales_money(goodsMapper.today_profit(getDay.getSumDate(15).get(i)));
//            System.out.println(getDay.getSumDate(15).get(i)+"利润为："+
//                    goodsMapper.today_profit(getDay.getSumDate(15).get(i)));
            profit.add(sevenDay);
        }
        return profit;
    }
    //今日出货分类比例
    @Override
    public List<Pie> getCategory() {
        return goodsMapper.getCategory();
    }
}
